<?php
declare (strict_types=1);

namespace app\user\model\user;

use app\common\model\BaseModel;
use think\facade\Request;

/**
 * 定义充值配置模型
 */
class Recharge extends BaseModel
{
    /**
     * 表名
     * @var string
     */
    protected $name = 'recharge_config';

    /**
     * 设置自动写入时间
     * @var boolean
     */
    protected $autoWriteTimestamp = true;

    /**
     * 无需创建时间
     * @var boolean
     */
    protected $createTime = false;

    /**
     * 定义表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 定义字段类型
     * @var array
     */
    protected $type = [
        'update_time'  => 'integer',
        "price"        => 'float',
        "balance"      => 'float',
        "give_balance" => 'float',
    ];

    /**
     * IOS配置查询条件
     * Author: Martinsun <syh@sunyonghong.com>
     * Date: 2020/9/29
     * @param $query
     */
    public function scopeIos($query)
    {
        $query->where('is_ios', 1);
    }

    /**
     * scopeMhm
     * Author: 亓官雨树 <lucky.max@foxmail.com>
     * Date: 23/07/20
     *
     * @param $query
     */
    public function scopeMhm($query)
    {
        $query->where('mhm_id', request()->mhm_id);
    }
}
